package com.test.xshang.pattern.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @BelongsProject: simpleframework
 * @BelongsPackage: com.test.xshang.pattern.proxy.jdkproxy
 * @Author: xshang
 * @CreateTime: 2023-06-26  21:55
 * @Description: TODO
 * @Version: 1.0
 */
public class JdkDynamicProxyUtil {
    public static <T> T newProxyInstance(T tagetObject , InvocationHandler handler) {
        ClassLoader classLoader = tagetObject.getClass().getClassLoader();
        Class<?>[] interfaces = tagetObject.getClass().getInterfaces();
        return (T) Proxy.newProxyInstance(classLoader, interfaces, handler);
    }
}
